<?php
class Clients_Controller extends Template_Controller {

	public $template = 'client/index';
	public $language = '';
    public function __construct()
    {
        parent::__construct();
        
        //Css
        //$this->template->css = $this->site['theme_url'].'article/article.css';
       	$this->language = $this->get_client_lang();
    }
    
	public function __call($method, $arguments)
	{
		// Disable auto-rendering
		$this->auto_render = FALSE;
	}
	
    public function index()
    {	
		$this->page();
		
    }
    public function page()
    {
    	$this->template->content = new View('clients/index');
		$model = new Testimonials_Model(); 
		$this->pagination = new Pagination(array(
    		'base_url'    => 'clients/page/',
		    'uri_segment'    => 'page',
		    'total_items'    => ORM::factory('testimonials')->count_all(),
		    'items_per_page' => 4,
		    'style'          => 'digg',
			'auto_hide'      => TRUE,
		));
		$this->db->limit($this->pagination->items_per_page,$this->pagination->sql_offset);
		
		$mTestimonials = $model->get_with_active($this->language);
		$this->template->content->mTestimonials= $mTestimonials;
		//
		$model = new Cate_Model(); 
		$mCate = $model->get_with_active($this->language);
		$this->template->content->mCate= $mCate;		
		//solutoin
		$model = new Studies_Model(); 
		$this->db->limit(10,0);	
		$mStudies = $model->get_with_active($this->language);
		$this->template->content->mStudies= $mStudies;
		//coaching
		
		$model = new Client_Model(); 
		$mClients = $model->get_with_active($this->language);
		$this->template->content->mClients= $mClients;
		
    }
    public function testimonials($id)
    {
    	$this->template->content = new View('clients/testimonials');
    	$language = $this->get_client_lang();
		$model = new Testimonials_Model(); 
		$this->db->where('testimonials_content.testimonials_id',$id);
		$mlist = $model->get_with_active($language);
    	$this->template->content->mr = $mlist[0];
		
		$mlistOther = $this->other_testimonials($id);
		//print_r($mlistOther);
		$this->template->content->mlistOther = $mlistOther;
    }
	
	 public function studies($id)
    {
    	$this->template->content = new View('clients/studies');
    	$language = $this->get_client_lang();
		$model = new Studies_Model(); 
		$this->db->where('studies_content.studies_id',$id);
		$mlist = $model->get_with_active($language);
    	$this->template->content->mr = $mlist[0];
		
		$mlistOther = $this->other_studies($id);
		//print_r($mlistOther);
		$this->template->content->mlistOther = $mlistOther;
		
    }
	 public function clients($id)
    {
    	$this->template->content = new View('clients/clients');
    	$language = $this->get_client_lang();
		$model = new Client_Model(); 
		$this->db->where('clent_content.clients_id',$id);
		$mlist = $model->get($language);
    	$this->template->content->mr = $mlist[0];
    }
	public function other_testimonials($id)

    {

    	$language = $this->get_client_lang();

		$model = new Testimonials_Model(); 

		$this->db->where('testimonials.testimonials_id <>',$id);

		$mlist = $model->get_with_active($language);

    	return $mlist;

    }
	public function other_studies($id)

    {

    	$language = $this->get_client_lang();

		$model = new Studies_Model(); 

		$this->db->where('studies.studies_id <>',$id);

		$mlist = $model->get_with_active($language);

    	return $mlist;

    }
}
?>